package com.infore.remoteControl.controller;

import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.infore.remoteControl.constant.Constants;
import com.infore.remoteControl.entity.protocolEntity.ProtocolData;
import com.infore.remoteControl.enums.ResultStatus;
import com.infore.remoteControl.select.dto.QueryParamDto;
import com.infore.remoteControl.service.IProtocolDataService;
import com.infore.remoteControl.util.ResultEntity;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
 * 协议数据控制器
 * @author Cold
 *
 */
@Api(value = "协议数据管理接口", tags = {"协议数据管理接口" })
@RestController
@RequestMapping("/protocolData")
public class ProtocolDataController {
	
	@Autowired
	IProtocolDataService iProtocolDataService;
	
	@ApiOperation(value = "查询协议数据通用接口")
	@ResponseBody
	@RequestMapping(value = "/query", method = RequestMethod.POST)
	public ResultEntity query(@RequestBody(required = false) QueryParamDto queryParamDto) {
		return iProtocolDataService.query(queryParamDto);
	}
	
	@ApiOperation(value = "编辑协议数据通用接口")
	@ResponseBody
	@RequestMapping(value = "/edit", method = RequestMethod.POST)
	public ResultEntity edit(List<ProtocolData> protocolDataList, MultipartFile file) {
		return iProtocolDataService.edit(protocolDataList, file);
	}
	
	@ApiOperation(value = "删除协议通用接口")
	@ApiImplicitParams({@ApiImplicitParam(name = "ids", value = "协议数据ID", paramType = "query", required = true, dataType = "String")})
	@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
	public ResultEntity delete(String ids) {
		if (StringUtils.isBlank(ids)) {
			return new ResultEntity(ResultStatus.ERROR, Constants.DELETE_FAILUE);
		}
		return iProtocolDataService.delete(ids);
	}
	
}
